home *** CD-ROM | disk | FTP | other *** search
- Path: anvil.ugrad.cs.ubc.ca!not-for-mail
- From: c2a192@ugrad.cs.ubc.ca (Kazimir Kylheku)
- Newsgroups: comp.lang.c
- Subject: Re: timimng an event in milli seconds.
- Date: 27 Feb 1996 07:21:17 -0800
- Organization: Computer Science, University of B.C., Vancouver, B.C., Canada
- Message-ID: <4gv7hdINNb8v@anvil.ugrad.cs.ubc.ca>
- References: <Pine.SUN.3.91.960218173348.23890B-100000@aloha.cc.columbia.edu>
- NNTP-Posting-Host: anvil.ugrad.cs.ubc.ca
-
- In article <Pine.SUN.3.91.960218173348.23890B-100000@aloha.cc.columbia.edu>,
- Gopal V. Sarikela <gvs3@columbia.edu> wrote:
- >
- >Hello everyone,
- > This might be a repeat question but i am sorry for asking.
- >I have access to Borland 4.0 compiler on DOS and Windows for IBM and gcc
- >and cc for UNIX.
- >
- > I am intersested in measuring time taken by an event like a key
- >hit or the user typing something.
- >
- > On the Borland compiler, the command int86(int, *REGS, *REGS) and
- >ti_hund gives the time in hundreth of a second, thats how we can time an
- >event.
- >
- > I am interested in _milli seconds_ can anybody help me? I am also
- >intersted in doing the same on the unix workstations at the university .
-
- There is a _standard_ function called clock(), you know... it gives a time in
- clock ticks, which you can divide by the clock tick period, given by
- CLOCKS_PER_SECOND. Don't forget to #include <time.h>.
-
- BTW, I think that this is normally measured in virtual process time, not real
- time. I doubt that you can get a more accurate timer without referring to
- something like gettimeofday(), which is a UNIX thing, not a standard function.
- gettimeofday() gives you a struct timeval, which contains seconds and
- milliseconds.
-
- I know that it is available on PC's, since the requestor side of a
- communication protocol of mine was recently ported to Windows/Winsock, and this
- code uses gettimeofday() to measure round-trip times.
- --
-
-